/**
 * @author zhoushengtao
 * @since 2012-8-24 下午2:33:35
 */

package com.stchou.superbrowser.ui.widget;

import com.stchou.superbrowser.activity.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

public class SuperToast extends Toast
{

    /**
     * @param context
     */
    public SuperToast(Context context)
    {
        super(context);
    }

    
    public static Toast makeLongText(Context context, CharSequence text) {
        Toast result = new Toast(context);
        
        //获取LayoutInflater对象
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
        //由layout文件创建一个View对象
        View layout = inflater.inflate(R.layout.toast, null);
        //实例化ImageView和TextView对象
        TextView textView = (TextView) layout.findViewById(R.id.text);
        textView.setText(text); 
        result.setView(layout);
        result.setDuration(Toast.LENGTH_LONG);      
        return result;
    }
    
    public static Toast makeShotText(Context context, CharSequence text) {
        Toast result = new Toast(context);
        
        //获取LayoutInflater对象
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
        //由layout文件创建一个View对象
        View layout = inflater.inflate(R.layout.toast, null);
        
        //实例化ImageView和TextView对象
        TextView textView = (TextView) layout.findViewById(R.id.text);
        textView.setText(text);
        result.setView(layout);
        result.setDuration(Toast.LENGTH_SHORT);
        return result;
    }
    
    public static Toast makeTextWithBackGround(Context context, CharSequence text,int duration,int resId)
    {
        Toast result = new Toast(context);
        
        //获取LayoutInflater对象
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
        //由layout文件创建一个View对象
        View layout = inflater.inflate(R.layout.toast, null);
        layout.setBackgroundResource(resId);
        //实例化ImageView和TextView对象
        TextView textView = (TextView) layout.findViewById(R.id.text);
        textView.setText(text);
        result.setView(layout);
        result.setDuration(duration);
        return result;
    }
}
